﻿<ribbon:RibbonWindow x:Class="The.NET_Downloader.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:ribbon="clr-namespace:Microsoft.Windows.Controls.Ribbon;assembly=RibbonControlsLibrary"
        Title="The .NET Downloader"
		x:Name="RibbonWindow"
		Width="1059" Height="480" MinWidth="640" MinHeight="480" xmlns:my="clr-namespace:The.NET_Downloader" xmlns:my1="clr-namespace:PhoenixControlLib;assembly=PhoenixControlLib" Icon="/The.NET_Downloader;component/Images/Download.ico" Loaded="RibbonWindow_Loaded" Closing="RibbonWindow_Closing">
    <ribbon:RibbonWindow.Resources>
        
        <my:DownloaderNameConvertor x:Key="DownloaderNameConvertor" />
        <my:DownloaderSizeConvertor x:Key="DownloaderSizeConvertor" />
        <my:DownloaderSpeedConvertor x:Key="DownloaderSpeedConvertor" />
        <my:DownloaderTimeRemainingConvertor x:Key="DownloaderTimeRemainingConvertor" />
        
        <BitmapImage x:Key="LargeImageSource1" UriSource="/The.NET_Downloader;component/Images/ICO/Blue/32/tool.ico" />
        <LinearGradientBrush x:Key="BackgroundBrush" StartPoint="0,0" EndPoint="0,1">
            <LinearGradientBrush.GradientStops>
                <GradientStopCollection>
                    <GradientStop Color="#FF6FBDE8" Offset="0"/>
                    <GradientStop Color="#FF4385BE" Offset="1"/>
                </GradientStopCollection>
            </LinearGradientBrush.GradientStops>
        </LinearGradientBrush>
        <LinearGradientBrush x:Key="HighlightBackgroundBrush" StartPoint="0,0" EndPoint="0,1">
            <LinearGradientBrush.GradientStops>
                <GradientStopCollection>
                    <GradientStop Color="#FF97d3f3" Offset="0"/>
                    <GradientStop Color="#FF4385BE" Offset="1"/>
                </GradientStopCollection>
            </LinearGradientBrush.GradientStops>
        </LinearGradientBrush>

        <LinearGradientBrush x:Key="BorderBrush" StartPoint="0,0" EndPoint="0,1">
            <LinearGradientBrush.GradientStops>
                <GradientStopCollection>
                    <GradientStop Color="#FFAFDDF6" Offset="0"/>
                    <GradientStop Color="#FF2969AA" Offset="1"/>
                </GradientStopCollection>
            </LinearGradientBrush.GradientStops>
        </LinearGradientBrush>

        <LinearGradientBrush x:Key="PressedBorderBrush" StartPoint="0,0" EndPoint="0,1">
            <LinearGradientBrush.GradientStops>
                <GradientStopCollection>
                    <GradientStop Color="#FF75aac7" Offset="0"/>
                    <GradientStop Color="#FF143c65" Offset="1"/>
                </GradientStopCollection>
            </LinearGradientBrush.GradientStops>
        </LinearGradientBrush>
        <Style x:Key="GridViewColumnHeaderGripper" TargetType="Thumb">
            <Setter Property="Width" Value="18"/>
            <Setter Property="Background" Value="#2e566b"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Thumb}">
                        <Border Padding="{TemplateBinding Padding}" Background="Transparent">
                            <Rectangle HorizontalAlignment="Center" Width="1" Fill="{TemplateBinding Background}"/>
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <Style x:Key="{x:Type GridViewColumnHeader}" TargetType="GridViewColumnHeader">
            <Setter Property="HorizontalContentAlignment" Value="Center"/>
            <Setter Property="VerticalContentAlignment" Value="Center"/>
            <Setter Property="Foreground" Value="#FFFFFF" />
            <Setter Property="Padding" Value="8"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="GridViewColumnHeader">
                        <Grid>
                            <Border Name="HeaderBorder" Padding="{TemplateBinding Padding}" BorderThickness="0,1,0,1" BorderBrush="{StaticResource BorderBrush}" Background="{StaticResource BackgroundBrush}">
                                <ContentPresenter Name="HeaderContent" Margin="0,0,0,1" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                            </Border>
                            <Thumb x:Name="PART_HeaderGripper" HorizontalAlignment="Right" Margin="0,0,-9,0" Style="{StaticResource GridViewColumnHeaderGripper}"/>
                        </Grid>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsMouseOver" Value="true">
                                <Setter TargetName="HeaderBorder" Property="Background" Value="{StaticResource HighlightBackgroundBrush}"/>
                            </Trigger>
                            <Trigger Property="IsPressed" Value="true">
                                <Setter TargetName="HeaderBorder" Property="Background" Value="{StaticResource PressedBorderBrush}"/>
                                <Setter TargetName="HeaderContent" Property="Margin" Value="1,1,0,0"/>
                            </Trigger>
                            <Trigger Property="IsEnabled" Value="false">
                                <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
            <Style.Triggers>
                <Trigger Property="Role" Value="Floating">
                    <Setter Property="Opacity" Value="0.7"/>
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="GridViewColumnHeader">
                                <Canvas Name="PART_FloatingHeaderCanvas">
                                    <Rectangle Fill="#60000000" Width="{TemplateBinding ActualWidth}" Height="{TemplateBinding ActualHeight}"/>
                                </Canvas>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Trigger>
                <Trigger Property="Role" Value="Padding">
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="GridViewColumnHeader">
                                <Border Name="HeaderBorder" BorderThickness="0,1,0,1" BorderBrush="{StaticResource BorderBrush}" Background="{StaticResource BackgroundBrush}"/>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Trigger>
            </Style.Triggers>
        </Style>
    </ribbon:RibbonWindow.Resources>
    <Grid x:Name="LayoutRoot">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <ribbon:Ribbon x:Name="Ribbon" SelectedIndex="0" SelectionChanged="Ribbon_SelectionChanged">
            <ribbon:Ribbon.ApplicationMenu>
                <ribbon:RibbonApplicationMenu Height="25" IsEnabled="True" IsMainMenu="True">
                    <ribbon:RibbonApplicationMenuItem Header="About"
                                                      x:Name="MenuItemAbout"
                                                      ImageSource="/The.NET_Downloader;component/Images/ICO/Blue/32/about.ico" Click="MenuItemAbout_Click" />
                    <ribbon:RibbonApplicationMenuItem Header="Exit"
                                                      x:Name="MenuItemtExit" Click="MenuItemtExit_Click" 
                                                      ImageSource="/The.NET_Downloader;component/Images/ICO/Blue/32/power.ico"/>
                </ribbon:RibbonApplicationMenu>
            </ribbon:Ribbon.ApplicationMenu>
            <ribbon:RibbonTab x:Name="DownloadTab" 
                              Header="Download">
                <ribbon:RibbonGroup x:Name="GroupBasic" 
                                    Header="Downloads">
                    <ribbon:RibbonButton x:Name="btnNewDownload" Click="btnNewDownload_Click"
                                         LargeImageSource="/The.NET_Downloader;component/Images/ICO/Blue/32/add.ico"
                                         Label="New Download" />
                    <ribbon:RibbonButton x:Name="btnDeleteDownload"
                                         SmallImageSource="/The.NET_Downloader;component/Images/ICO/Blue/32/del.ico"
                                         Label="Delete" Click="btnDeleteDownload_Click" />
                
                </ribbon:RibbonGroup>
                <ribbon:RibbonGroup x:Name="GroupAllD" 
                                    Header="Actions">
                    <ribbon:RibbonButton x:Name="btnForceStart"
                                         LargeImageSource="/The.NET_Downloader;component/Images/ICO/Green/32/object_13.ico"
                                         Label="Force Start" Click="btnForceStart_Click" />
                    <ribbon:RibbonButton x:Name="btnPause"
                                         LargeImageSource="/The.NET_Downloader;component/Images/ICO/Green/32/pause.ico"
                                         Label="Pause" Click="btnPauseAll_Click" />
                </ribbon:RibbonGroup>
                <ribbon:RibbonGroup x:Name="PriorityGroup" 
                                    Header="Priority">
                    <ribbon:RibbonButton x:Name="btnMoveUp" Height="38"
                                         LargeImageSource="/The.NET_Downloader;component/Images/ICO/Yellow/32/up_01.ico"
                                        Click="btnPauseAll_Click" />
                    <ribbon:RibbonButton x:Name="btnMoveDown" Height="38" 
                                         LargeImageSource="/The.NET_Downloader;component/Images/ICO/Yellow/32/down.ico"
                                        Click="btnPauseAll_Click" />
                </ribbon:RibbonGroup>
                <ribbon:RibbonGroup x:Name="CurPreset" 
                                    Header="Download Speed">
                    <my1:RadioToggleButton GroupName="CurrentPreset" Width="50" Height="50" Margin="5" Name="Preset1" FlowDirection="LeftToRight" IsChecked="True">
                        <Image Source="/The.NET_Downloader;component/Images/ICO/Blue/32/Forward.ico"></Image>
                    </my1:RadioToggleButton>
                    <my1:RadioToggleButton GroupName="CurrentPreset" Width="50" Height="50"  Margin="5"  HorizontalAlignment="Left" Name="Preset2" VerticalAlignment="Top">
                        <Image Source="/The.NET_Downloader;component/Images/ICO/Blue/32/Forward_01.ico"></Image>
                    </my1:RadioToggleButton>
                    <my1:RadioToggleButton  GroupName="CurrentPreset" Width="50" Height="50" Margin="5"  HorizontalAlignment="Left" Name="Preset3" VerticalAlignment="Top">
                        <Image Source="/The.NET_Downloader;component/Images/ICO/Blue/32/charts04.ico"></Image>
                    </my1:RadioToggleButton>
                </ribbon:RibbonGroup>

            </ribbon:RibbonTab>
            <ribbon:RibbonTab x:Name="HistoryTab" 
                              Header="History">
            </ribbon:RibbonTab>
            <ribbon:RibbonTab x:Name="OptionsTab" 
                              Header="Options">
                <ribbon:RibbonGroup x:Name="OptDlGroup" 
                                    Header="Settings">
                    <ribbon:RibbonButton x:Name="ButtonSave"
                                         LargeImageSource="{StaticResource LargeImageSource1}"
                                         Label="Save" />
                    <ribbon:RibbonButton x:Name="ButtonDefault"
                                         LargeImageSource="/The.NET_Downloader;component/Images/ICO/Blue/32/Repeat.ico"
                                         Label="Default" />
                </ribbon:RibbonGroup>
                <ribbon:RibbonGroup x:Name="OptEditGroup" 
                                    Header="Modify Preset" Width="200" >
                    <my1:RadioToggleButton GroupName="ModPresets" Width="50" Height="50" Margin="5" Name="ModPreset1">
                        <Image Source="/The.NET_Downloader;component/Images/ICO/Blue/32/Forward.ico"></Image>                
                    </my1:RadioToggleButton>
                    <my1:RadioToggleButton GroupName="ModPresets" Width="50" Height="50"  Margin="5" Name="ModPreset2">
                        <Image Source="/The.NET_Downloader;component/Images/ICO/Blue/32/Forward_01.ico"></Image>
                    </my1:RadioToggleButton>
                    <my1:RadioToggleButton  GroupName="ModPresets" Width="50" Height="50" Margin="5" Name="ModPreset3">
                        <Image Source="/The.NET_Downloader;component/Images/ICO/Blue/32/charts04.ico"></Image>
                    </my1:RadioToggleButton>
                </ribbon:RibbonGroup>
                <ribbon:RibbonGroup x:Name="GroupDownloadSettings" 
                                    Header="Download Settings">
                 <my:DownloadSettings HorizontalAlignment="Left" Width="300" x:Name="downloadSettings1" VerticalAlignment="Top" />
                </ribbon:RibbonGroup>
                <ribbon:RibbonGroup x:Name="GroupAdvancedOptions" 
                                    Header="Other">
                    <ribbon:RibbonButton x:Name="ButtonAdvancedOptions"                                         
                                         Label="Advanced" LargeImageSource="/The.NET_Downloader;component/Images/ICO/Yellow/32/tool.ico" Click="ButtonAdvancedOptions_Click" />
                </ribbon:RibbonGroup>


            </ribbon:RibbonTab>
            <ribbon:RibbonTab x:Name="StatisticsTab" 
                              Header="Statistics">
                <ribbon:RibbonGroup x:Name="StatUsageGroup" 
                                    Header="Usage" Width="300">
                    <Label>Total Downloaded:</Label>
                    <Label>Total Hours Downloaded:</Label>
                    <Label>Average Speed:</Label>
                </ribbon:RibbonGroup>
            </ribbon:RibbonTab>
        </ribbon:Ribbon>
        <Grid Grid.Row="1">
            <ListView Name="TestView" Visibility="Collapsed">
                <ListViewItem>ONe</ListViewItem>
                <ListViewItem>TWo</ListViewItem>
                <ListViewItem>ONe</ListViewItem>
            </ListView>
                <ListView Grid.Row="1" Name="downloadsListView" ItemsSource="{Binding DownloadList}" MouseDoubleClick="downloadsListView_MouseDoubleClick">
                    <ListView.ContextMenu>
                        <ContextMenu>
                        <MenuItem Header="Open"></MenuItem>
                        <MenuItem Header="Pause"></MenuItem>
                        <MenuItem Header="Restart"></MenuItem>
                        <MenuItem Header="Force"></MenuItem>
                        <MenuItem Header="Delete"></MenuItem>
                        <MenuItem Header="Properties" Click="MenuItem_Click"></MenuItem>
                    </ContextMenu>
                    </ListView.ContextMenu>
                    <ListView.View>
                        <GridView>
                            <GridViewColumn Width="250" Header="Name" DisplayMemberBinding="{Binding LocalFile, Converter={StaticResource DownloaderNameConvertor}}" />
                            <GridViewColumn Width="80" Header="Size" DisplayMemberBinding="{Binding FileSize, Converter={StaticResource DownloaderSizeConvertor}}" />
                            <GridViewColumn Width="100" Header="Time Left" DisplayMemberBinding="{Binding Converter={StaticResource DownloaderTimeRemainingConvertor}}" />
                            <GridViewColumn Width="140" Header="Status" DisplayMemberBinding="{Binding State}" />
                            <GridViewColumn Width="50" Header="Speed" DisplayMemberBinding="{Binding Rate, Mode=OneWay,Converter={StaticResource DownloaderSpeedConvertor}}" />
                            <GridViewColumn Width="140" Header="Progress">
                                <GridViewColumn.CellTemplate>
                                    <DataTemplate>
                                        <ProgressBar Value="{Binding Progress, Mode=OneWay}" Width="120" Height="16" Maximum="100"></ProgressBar>
                                    </DataTemplate>
                                </GridViewColumn.CellTemplate>
                            </GridViewColumn>
                            <GridViewColumn Width="200" Header="Message" DisplayMemberBinding="{Binding StatusMessage}" />

                        </GridView>
                    </ListView.View>
                </ListView>
        </Grid>
        <StatusBar Grid.Row="1" Height="28" Name="statusBar1" VerticalAlignment="Bottom" />
        <ProgressBar Grid.Row="1" Height="18" HorizontalAlignment="Left" Margin="12,0,0,5" Name="progressBar1" VerticalAlignment="Bottom" Width="200" />
        <Label Content="Speed: " Grid.Row="1" Height="28" HorizontalAlignment="Right" Name="speedlabel" VerticalAlignment="Bottom" Width="93" Margin="0,0,12,0" />
    </Grid>
</ribbon:RibbonWindow>
